package com.gee.spring.boot.influxdb.core.util;

import com.gee.spring.boot.influxdb.core.convertor.Convertor;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * @author gepengjun
 * @since 2024/4/24 16:14
 */
@Component
public class AppContextUtil implements ApplicationContextAware {

    private static ApplicationContext applicationContext;


    public static Convertor getConvertor(Class<? extends Convertor> clazz){
        return applicationContext.getBean(clazz);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        AppContextUtil.applicationContext = applicationContext;
    }
}
